import { defineStore } from 'pinia'

type MainStateProps = {
  sideShrink: boolean
  manyBtnShrink: boolean
  isReal: boolean
  isMute: boolean
  sig: number
  runSpeedSim: number
}

const useMainStore = defineStore('main', {
  state: (): MainStateProps => ({
    sideShrink: false,
    manyBtnShrink: false,
    isReal: true,
    isMute: true,
    sig: 0,
    runSpeedSim: 0,
  }),
  getters: {},
  actions: {
    setSig(sig: number) {
      this.sig = sig
      this.runSpeedSim = 0
    },
    setIsReal(isReal: boolean) {
      this.isReal = isReal
      this.runSpeedSim = 0
    },
    setIsMute(isMute: boolean) {
      this.isMute = isMute
    },
    setSideShrink(shrink?: boolean) {
      if (shrink === undefined) {
        this.sideShrink = !this.sideShrink
      } else {
        this.sideShrink = shrink
      }
    },
    setManyBtnShrink(shrink?: boolean) {
      if (shrink === undefined) {
        this.manyBtnShrink = !this.manyBtnShrink
      } else {
        this.manyBtnShrink = shrink
      }
    },
    setRunSpeedSim(runSpeedSim: number) {
      this.runSpeedSim = runSpeedSim
    },
  },
})

export default useMainStore
